<?php 
	$_SESSION['realpage'] = true;
?>
<!DOCTYPE HTML>
<?php 
require_once "./class.GeneralServices.php";
require_once "./class.User.php";
$error = false;
session_start();
?>
<html>
<head>
<?php require_once "./HtmlIncludes.php";?>

<?php 
$User = GeneralServices::getService()->getUser($_SESSION['puid']);

?>
<title>Insert title here</title>
</head>
	<body onload="load();">
    <script type="text/javascript">
		function load()
		{
			var ur = window.parent.document.URL;			
			if(ur.substring(ur.length - 15, ur.length) != "Pages/panes.php")
				window.location.replace("./panes.php");
		}
    </script>
		<div class="PaneHeader"><span style="text-align: center;"><?php echo $User->FirstName;?>  <?php echo $User->Surname?>'s Profile Page</span></div>
   		<div>
   			<fieldset>
				<label for="Firstname">First name</label>
				<br>
				<input disabled="disabled" type="text" name="Firstname" id="Firstname" value="<?php if(isset($User)){echo $User->FirstName;}?>" class="text ui-widget-content ui-corner-all" />	
				<br>
				<label for="Lastname">Last name</label>
				<br>
				<input disabled="disabled" type="text" name="Lastname" id="Lastname" value="<?php if(isset($User)){echo $User->Surname;}?>" class="text ui-widget-content ui-corner-all" />
				<br>						
				<label for="Email">Email</label>
				<br>
				<input disabled="disabled" type="text" name="Email" id="Email" value="<?php if(isset($User)){echo $User->Email;}?>" class="text ui-widget-content ui-corner-all" />	
				<br>
				<label  for="Birthday">Birthday</label>
				<br>
				<input disabled="disabled" type="text" name="Birthday" id="Birthday" value="<?php if(isset($User)){echo $User->birthday;}?>" class="text ui-widget-content ui-corner-all" />
				<br>
				<label for="About">About</label>
				<br>
				<textarea disabled="disabled" cols="16" rows="3" name="about" id="About" class="text ui-widget-content ui-corner-all"><?php if(isset($User)){echo str_replace('<br>', "\n", $User->About);}?></textarea>	
			</fieldset>
   		</div>
   		<span id="goToWall" onclick="GoToWall();">Go To Wall</span>
   <script type="text/javascript">
		$('#goToWall').button();

		function GoToWall()
		{
			if (window.XMLHttpRequest)
			{// code for IE7+, Firefox, Chrome, Opera, Safari
				xmlhttp=new XMLHttpRequest();
			}
			else
			{// code for IE6, IE5
				xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			xmlhttp.onreadystatechange=function()
			{
				if (xmlhttp.readyState==4 && xmlhttp.status==200)
			    {
				    if(xmlhttp.responseText == 'false')
				    {
						alert('false');
				    }
				    else
				    {
				    	setGroupId(xmlhttp.responseText);
				    }
				}
			}
			xmlhttp.open("GET","./ajax.php?method=GoToWall&sid="+"<?php echo session_id(); ?>"+"&uid="+"<?php echo $User->uid?>",true);
			xmlhttp.send();
		}

		function setGroupId(gid)
	    {
	    	if(gid != null)
	    	{
	    		if (window.XMLHttpRequest)
	    		{// code for IE7+, Firefox, Chrome, Opera, Safari
	    			xmlhttp=new XMLHttpRequest();
	    		}
	    		else
	    		{// code for IE6, IE5
	    			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	    		}
	    		xmlhttp.onreadystatechange=function()
	    		{
	    			if (xmlhttp.readyState==4 && xmlhttp.status==200)
	    		    {
	    			    if(xmlhttp.responseText == 'false')
	    			    {
	    					alert('false');
	    			    }
	    			    else
	    			    {
	    			    	ShowGroupTab(gid);
	    			    }
	    			}
	    		};
	    		xmlhttp.open("GET","./ajax.php?method=setGid&sid="+"<?php echo session_id(); ?>"+"&gid="+gid,true);
	    		xmlhttp.send();
	    	}
	    }
   </script>
   </body>
</html>
	